package tech.dingxin;

import org.bytedeco.javacpp.BytePointer;
import static org.bytedeco.opencv.global.opencv_imgcodecs.*;
import org.bytedeco.opencv.opencv_core.Mat;
import tech.dingxin.codec.Image;

import tech.dingxin.codec.JavaCVUtil;
import tech.dingxin.protobuf.FrameProtobuf;

import javax.swing.text.html.ImageView;
import java.util.ArrayList;

public class Test {

    static void uppp(){

        double time = System.currentTimeMillis();
        String filename = "A:\\nrvs\\src\\main\\resources\\1.jpg";
        Mat image = imread(filename);
        System.out.println("读取图片用时:"+(System.currentTimeMillis()-time));


        time = System.currentTimeMillis();
        BytePointer bytePointer = new BytePointer();
        imencode(".jpg", image, bytePointer);
        String strEncode = bytePointer.getString();
        System.out.println("编码图片用时:"+(System.currentTimeMillis()-time));

        time = System.currentTimeMillis();
        FrameProtobuf.Frame frame = FrameProtobuf.Frame.newBuilder()
                .setData(strEncode)
                .build();
        System.out.println("序列化图片用时:"+(System.currentTimeMillis()-time));

    }

    public static void main(String[] args) {
        uppp();


    }
}
